package it.unibo.refolding.common;

import java.util.Objects;

import it.unimi.dsi.fastutil.doubles.Double2IntSortedMap;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

public class WindowFrequencyFunctionInput {
	public final int from;
    public final int to;
	public final Double2IntSortedMap sortedMap;

	public WindowFrequencyFunctionInput(int from, int to, Double2IntSortedMap sortedMap) {
		this.from = from;
		this.to = to;
		assert to - from == CommonThings.sum(sortedMap.values());
		this.sortedMap = sortedMap;
	}

	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}

    @Override
    public int hashCode() {
        return Objects.hash(from, to, sortedMap);
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof WindowFrequencyFunctionInput)) {
            return false;
        }
        WindowFrequencyFunctionInput other = (WindowFrequencyFunctionInput) obj;
        return from == other.from & to == other.to && sortedMap.equals(other.sortedMap);
   }
}
